package com.ers.controller;

import java.sql.SQLException;
import java.util.Random;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ExceptionHandler;

public abstract class BaseController {
	@ExceptionHandler
	public String exception(HttpServletRequest request,HttpServletResponse response,Exception e){
		request.setAttribute("exceptionMessage", e.getMessage());
		//int status = response.getStatus();
		 if(e instanceof SQLException) 
	            return "error"; 
		 else if(e instanceof IllegalArgumentException)
			 return "hr/login";
		 else
			 return "error";
	}
}
